
#include <rthw.h>
#include <rtthread.h>
#include "board.h"
#include "ev_tick_hook.h"
#include "ev_init.h"

int main()
{
    rt_hw_interrupt_disable();

    /* board level initialization
     * NOTE: please initialize heap inside board initialization.
     */
    driv_board_init(1);

    /* timer system initialization */
    rt_system_timer_init();

    /* scheduler system initialization */
    rt_system_scheduler_init();

    /* create init_thread */
    ev_init();

    /* timer thread initialization */
    rt_system_timer_thread_init();

    /* idle thread initialization */
    rt_thread_idle_init();

    /* start scheduler */
    rt_system_scheduler_start();

    /* never reach here */
    return 0;

}

void SysTick_Handler(void)
{
    rt_interrupt_enter();

    rt_base_t level = rt_hw_interrupt_disable();
    rt_tick_increase();
    ev_tick_hook_schedule();
    driv_cpu_reboot_check();
    driv_tick_inc();
    rt_hw_interrupt_enable(level);

    rt_interrupt_leave();
}
